<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ActionDispatch::Http::Cache::Request</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="../../../../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../../css/github.css" type="text/css" media="screen" />
<script src="../../../../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../../../../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>     
    <div class="banner">
        
            <span>Ruby on Rails v4.0.0</span><br />
        
        <h1>
            <span class="type">Module</span> 
            ActionDispatch::Http::Cache::Request 
            
        </h1>
        <ul class="files">
            
            <li><a href="../../../../files/actionpack/lib/action_dispatch/http/cache_rb.html">actionpack/lib/action_dispatch/http/cache.rb</a></li>
            
        </ul>
    </div>
    <div id="bodyContent">
        <div id="content">
  


  


  
  


  


  
    <!-- Method ref -->
    <div class="sectiontitle">Methods</div>
    <dl class="methods">
      
        <dt>E</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Request.html#method-i-etag_matches-3F">etag_matches?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>F</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Request.html#method-i-fresh-3F">fresh?</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>I</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Request.html#method-i-if_modified_since">if_modified_since</a>,
              </li>
            
              
              <li>
                <a href="Request.html#method-i-if_none_match">if_none_match</a>,
              </li>
            
              
              <li>
                <a href="Request.html#method-i-if_none_match_etags">if_none_match_etags</a>
              </li>
            
          </ul>
        </dd>
      
        <dt>N</dt>
        <dd>
          <ul>
            
              
              <li>
                <a href="Request.html#method-i-not_modified-3F">not_modified?</a>
              </li>
            
          </ul>
        </dd>
      
    </dl>
  

  



  

    

    

    
      <!-- Section constants -->
      <div class="sectiontitle">Constants</div>
      <table border='0' cellpadding='5'>
        
          <tr valign='top'>
            <td class="attr-name">HTTP_IF_MODIFIED_SINCE</td>
            <td>=</td>
            <td class="attr-value">'HTTP_IF_MODIFIED_SINCE'.freeze</td>
          </tr>
          
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"></td>
            </tr>
          
        
          <tr valign='top'>
            <td class="attr-name">HTTP_IF_NONE_MATCH</td>
            <td>=</td>
            <td class="attr-value">'HTTP_IF_NONE_MATCH'.freeze</td>
          </tr>
          
            <tr valign='top'>
              <td>&nbsp;</td>
              <td colspan="2" class="attr-desc"></td>
            </tr>
          
        
      </table>
    


    


    <!-- Methods -->
        
      <div class="sectiontitle">Instance Public methods</div>
      
        <div class="method">
          <div class="title method-title" id="method-i-etag_matches-3F">
            
              <b>etag_matches?</b>(etag)
            
            <a href="Request.html#method-i-etag_matches-3F" name="method-i-etag_matches-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-etag_matches-3F_source')" id="l_method-i-etag_matches-3F_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/6893c23f48d2707714240a1ae2a410a0661aa3a5/actionpack/lib/action_dispatch/http/cache.rb#L30" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-etag_matches-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/http/cache.rb, line 30</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">etag_matches?</span>(<span class="ruby-identifier">etag</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">etag</span>
    <span class="ruby-identifier">etag</span> = <span class="ruby-identifier">etag</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/^\&quot;|\&quot;$/</span>, <span class="ruby-string">&quot;&quot;</span>)
    <span class="ruby-identifier">if_none_match_etags</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">etag</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-fresh-3F">
            
              <b>fresh?</b>(response)
            
            <a href="Request.html#method-i-fresh-3F" name="method-i-fresh-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              <p>Check response freshness (Last-Modified and ETag) against request
If-Modified-Since and If-None-Match conditions. If both headers are
supplied, both must match, or the request is not considered fresh.</p>
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-fresh-3F_source')" id="l_method-i-fresh-3F_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/6893c23f48d2707714240a1ae2a410a0661aa3a5/actionpack/lib/action_dispatch/http/cache.rb#L40" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-fresh-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/http/cache.rb, line 40</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">fresh?</span>(<span class="ruby-identifier">response</span>)
  <span class="ruby-identifier">last_modified</span> = <span class="ruby-identifier">if_modified_since</span>
  <span class="ruby-identifier">etag</span>          = <span class="ruby-identifier">if_none_match</span>

  <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">last_modified</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">etag</span>

  <span class="ruby-identifier">success</span> = <span class="ruby-keyword">true</span>
  <span class="ruby-identifier">success</span> <span class="ruby-operator">&amp;&amp;=</span> <span class="ruby-identifier">not_modified?</span>(<span class="ruby-identifier">response</span>.<span class="ruby-identifier">last_modified</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">last_modified</span>
  <span class="ruby-identifier">success</span> <span class="ruby-operator">&amp;&amp;=</span> <span class="ruby-identifier">etag_matches?</span>(<span class="ruby-identifier">response</span>.<span class="ruby-identifier">etag</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">etag</span>
  <span class="ruby-identifier">success</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-if_modified_since">
            
              <b>if_modified_since</b>()
            
            <a href="Request.html#method-i-if_modified_since" name="method-i-if_modified_since" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-if_modified_since_source')" id="l_method-i-if_modified_since_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/6893c23f48d2707714240a1ae2a410a0661aa3a5/actionpack/lib/action_dispatch/http/cache.rb#L10" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-if_modified_since_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/http/cache.rb, line 10</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">if_modified_since</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">since</span> = <span class="ruby-identifier">env</span>[<span class="ruby-constant">HTTP_IF_MODIFIED_SINCE</span>]
    <span class="ruby-constant">Time</span>.<span class="ruby-identifier">rfc2822</span>(<span class="ruby-identifier">since</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-if_none_match">
            
              <b>if_none_match</b>()
            
            <a href="Request.html#method-i-if_none_match" name="method-i-if_none_match" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-if_none_match_source')" id="l_method-i-if_none_match_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/6893c23f48d2707714240a1ae2a410a0661aa3a5/actionpack/lib/action_dispatch/http/cache.rb#L16" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-if_none_match_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/http/cache.rb, line 16</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">if_none_match</span>
  <span class="ruby-identifier">env</span>[<span class="ruby-constant">HTTP_IF_NONE_MATCH</span>]
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-if_none_match_etags">
            
              <b>if_none_match_etags</b>()
            
            <a href="Request.html#method-i-if_none_match_etags" name="method-i-if_none_match_etags" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-if_none_match_etags_source')" id="l_method-i-if_none_match_etags_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/6893c23f48d2707714240a1ae2a410a0661aa3a5/actionpack/lib/action_dispatch/http/cache.rb#L20" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-if_none_match_etags_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/http/cache.rb, line 20</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">if_none_match_etags</span>
  (<span class="ruby-identifier">if_none_match</span> <span class="ruby-operator">?</span> <span class="ruby-identifier">if_none_match</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\s*,\s*/</span>) <span class="ruby-operator">:</span> []).<span class="ruby-identifier">collect</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">etag</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">etag</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/^\&quot;|\&quot;$/</span>, <span class="ruby-string">&quot;&quot;</span>)
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
        
        <div class="method">
          <div class="title method-title" id="method-i-not_modified-3F">
            
              <b>not_modified?</b>(modified_at)
            
            <a href="Request.html#method-i-not_modified-3F" name="method-i-not_modified-3F" class="permalink">Link</a>
          </div>
          
          
            <div class="description">
              
            </div>
          
          
          
          
          
            
            <div class="sourcecode">
              
              <p class="source-link">
                Source: 
                <a href="javascript:toggleSource('method-i-not_modified-3F_source')" id="l_method-i-not_modified-3F_source">show</a>
                
                  | <a href="https://github.com/rails/rails/blob/6893c23f48d2707714240a1ae2a410a0661aa3a5/actionpack/lib/action_dispatch/http/cache.rb#L26" target="_blank" class="github_url">on GitHub</a>
                
              </p>
              <div id="method-i-not_modified-3F_source" class="dyn-source">
                <pre><span class="ruby-comment"># File actionpack/lib/action_dispatch/http/cache.rb, line 26</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword ruby-title">not_modified?</span>(<span class="ruby-identifier">modified_at</span>)
  <span class="ruby-identifier">if_modified_since</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">modified_at</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">if_modified_since</span> <span class="ruby-operator">&gt;=</span> <span class="ruby-identifier">modified_at</span>
<span class="ruby-keyword">end</span></pre>
              </div>
            </div>
            
          </div>
                    </div>

    </div>
  </body>
</html>    